package com.itheima.admin.listener;

import com.itheima.admin.service.WemediaNewsAutoScanService;
import com.itheima.common.constants.BusinessConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
@Slf4j
public class WemediaNewsAutoScanListener {

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

   /* @Autowired
    private  WemediaNewsAutoScanService wemediaNewsAutoScanService;*/

    @KafkaListener(topics = BusinessConstants.MqConstants.WM_NEWS_AUTO_SCAN_TOPIC)
    public void autoScanWemediaNews(ConsumerRecord<String,String> record){

        String topic = record.topic();
        int partition = record.partition();
        String newId = record.value();
        String id = UUID.randomUUID().toString();

        log.info("自动审核开始topic={},partition={},newId={},id={}"+topic,partition,newId,id);
        //UUID

        wemediaNewsAutoScanService.autoScanWemediaNewsById(newId,id);

        log.info("自动审核结束topic={},partition={},newId={},id={}"+topic,partition,newId,id);

    }



}
